<%@ page import="com.bjpowernode.oa.bean.Dept" %>
<%@ page import="java.util.List,com.bjpowernode.oa.bean.Dept" %>
<%@ page contentType="text/html;charset=utf-8" %>
<!DOCTYPE html>
<html lang='en'>
    <head>
        <meta charset='UTF-8'>
        <title>List Page</title>
    </head>
    <body>
        <%--显示一个登录名，session不能为false 不然session就不能用了--%>
        <h3>欢迎<%=session.getAttribute("username")%></h3>
        <a href="<%=request.getContextPath()%>/user/exit">退出系统</a>

        <script type='text/javascript'>
            function del(deptno){
                var ok=window.confirm('亲，请确认删除');
                if(ok){
                    document.location.href='<%=request.getContextPath()%>/dept/delete?deptno='+deptno;
                }
            }
        </script>
        <h1 align='center'>部门列表</h1>
        <hr/>
        <table border='1px' align='center' width='50%'>
            <tr>
                <th>序号</th>
                <th>部门编号</th>
                <th>部门名称</th>
                <th>操作</th>
            </tr>
            <%
                int i=0;
                List<Dept> deptList= (List<Dept>)request.getAttribute("deptList");
                for(Dept dept:deptList){
            %>

            <tr>
                <td><%=++i%></td>
                <td><%=dept.getDeptno()%></td>
                <td><%=dept.getPname()%></td>
                <td>
                    <a href='<%=request.getContextPath()%>/dept/detail?f=modify&deptno=<%=dept.getDeptno()%>'>修改</a>
                    <a href='javascript:void(0)' onclick='del(<%=dept.getDeptno()%>)'>删除</a>
                    <a href='<%=request.getContextPath()%>/dept/detail?f=detail&deptno=<%=dept.getDeptno()%>'>详情</a>
                </td>
            </tr>

            <%
                }
            %>
        </table>
        <hr/>
        <a href='<%=request.getContextPath()%>/old/add.jsp.jsp'>新增部门</a>
    </body>
</html>